import axios from 'axios';

axios.defaults.headers['Content-Type'] = 'application/json';
// axios.defaults.baseURL = '/api'
// axios.defaults.baseURL = 'http://101.43.217.252:666'
const service = axios.create({
    // baseURL: 'http://127.0.0.1:8000',
    timeout: 5000
});
// 请求拦截器
service.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);
// 响应拦截器
service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

export default service;
